package com.dc.refactoring._3_重新组织数据._14_ReplaceSubClassWithFields.step3;

/**
 * Description: Person 人 抽象类
 * @author: gdc
 * @date: 2020/12/4
 * @version 1.0
 */
public abstract class Person {

    private final boolean isMale;
    private final char code;

    protected Person(boolean isMale, char code) {
        this.isMale = isMale;
        this.code = code;
    }

    static Person createMale(){
        return new Male();
    }

    static Person createFemale(){
        return new Female();
    }

    // 【6】父类中新建字段的访问函数,并在子类中获取方法删除
    boolean isMale(){
        return isMale;
    }

    char getCode(){
        return code;
    }

}


class Male extends Person {

    public Male() {
        super(true, 'M');
    }

    // 删除原访问函数
}

class Female extends Person {

    public Female() {
        super(false, 'F');
    }

    // 删除原访问函数

}